Page({

    /**
     * 页面的初始数据
     */
    data: {
        userInfo: {},
        tempFilePaths: [], //修改选择的图片路径
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this;
        wx.getUserInfo({
            success(res) {
                console.log(res)
                that.setData({
                    userInfo: res.userInfo
                })
            },
            fail(res) {
                console.log(`getUserInfo调用失败`);
            }
        });
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function (options) {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    //修改头像
    updateAvatarUrl: function (e) {
        var that = this;
        wx.chooseImage({
            count: 1,
            sizeType: ['original', 'compressed'],
            sourceType: ['album', 'camera'],
            success(res) {
                that.setData({
                    tempFilePaths: res.tempFilePaths
                })
                console.log(that.data.tempFilePaths)
                debugger
            },
            fail(res) {

            }
        })
    },
    save: function (e) {
        console.log(e)
        let nickName = e.detail.value.nickname;
        let sign = e.detail.value.sign;
        console.log("昵称", nickName)
        console.log('签名', sign)
        wx.uploadFile({
            url: '',
            filePath: that.data.tempFilePaths,
            name: 'img',
            success(res) {
                if (res.statusCode === 200) {
                    console.log(`uploadFile调用成功 ${res.data}`);
                }
            },
            fail(res) {
                console.log(`uploadFile调用失败`);
            }
        });
    }
})